﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Empires.Infrastructure.Entities.Entity;

namespace Empires.Biz
{
    public class FirmBiz
    {
        public static Corporation CreateNewFirm(Corporation firm)
        {
            if (firm != null && !String.IsNullOrEmpty(firm.Master))
            {
                var user = new User().Find(firm.Master);
                if (user != null && user.IsActivate && !user.IsRefuse)
                {
                    if (!new Corporation().Any(c => c.Master == user.UserName))
                    {
                        firm.PostAdd();
                        return firm;
                    }
                }
            }
            return null;
        }
    }
}
